//
//  WmcBundleEx.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/3/1.
//

import UIKit


private var kwmc_bundle = "kwmc_bundle"

extension Bundle {
    /// 水印相机专用Bundle
    static var WmcBundle: Bundle {
        return Bundle.main.wmc_bundle
    }

    /// 水印相机专用Bundle
    var wmc_bundle: Bundle {
        set { YPRuntime.Set(object: self, key:  &kwmc_bundle, value:  newValue) }
        get { // 懒加载bundle
            guard let bundle: Bundle = YPRuntime.GetObject(self, key: &kwmc_bundle) else {
                guard let url = Bundle.main.url(forResource: "YPWatermarkCamera",
                                                withExtension: "bundle"),
                    let WmcBundle = Bundle(url: url) else { return .main }
                YPRuntime.Set(object: self, key:  &kwmc_bundle, value:  WmcBundle)
                return WmcBundle
            }
            return bundle
        }
    }
}
